[MNG-8547] Introduce Event/Listener hierarchy with ExecutionEvent and ExecutionListener - #13058
[MNG-8547] Introduce Event/Listener hierarchy with ExecutionEvent and ExecutionListener#13058gnodet wants to merge 1 commit into
Conversation
… ExecutionListener Introduce a base Event/Listener hierarchy to support multiple event families (execution, repository, etc.) through a single registration point on Session. - Event: minimal base interface with session() accessor - ExecutionEvent: typed execution event (extends Event) with project(), mojoExecution(), exception() accessors - ExecutionListener: typed callbacks (extends Listener) with per-event-type default methods - ExecutionEventType: renamed from EventType for clarity - EventType: kept as @deprecated alias - Listener: refactored to base marker, onEvent() deprecated - DefaultEvent: implements ExecutionEvent with noun-style accessors - EventSpyImpl: dispatches to both legacy and typed listeners
cb6f143 to
4bda27d
Compare
gnodet
left a comment
There was a problem hiding this comment.
Solid API design — the hierarchy cleanly separates execution events from the base marker, and the backward compatibility story is well thought out (deprecated bridge methods, dual dispatch). Two minor observations below.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
| case PROJECT_FAILED -> listener.projectFailed(event); | ||
| case MOJO_SKIPPED -> listener.mojoSkipped(event); | ||
| case MOJO_STARTED -> listener.mojoStarted(event); | ||
| case MOJO_SUCCEEDED -> listener.mojoSucceeded(event); |
There was a problem hiding this comment.
💡 Suggestion (low): The default branch is unreachable — all 17 ExecutionEventType values are explicitly handled. Removing it turns this into an exhaustive switch, so the compiler will flag any future enum additions as a compile error rather than silently dropping them.
| case MOJO_SUCCEEDED -> listener.mojoSucceeded(event); | |
| case FORKED_PROJECT_FAILED -> listener.forkedProjectFailed(event); |
| * @see ExecutionListener | ||
| * @since 4.0.0 | ||
| * @since 4.1.0 (renamed from {@link EventType}) | ||
| */ |
There was a problem hiding this comment.
💡 Suggestion (low): @since 4.0.0 is misleading — this type is new in 4.1.0. EventType existed in 4.0.0, but ExecutionEventType didn't. The second @since tag clarifies the rename, but the first tag should match the actual introduction version.
| */ | |
| * @since 4.1.0 (renamed from {@link EventType}) |
Description
Introduce a base
Event/Listenerhierarchy to support multiple event families (execution, repository, etc.) through a single registration point onSession.This PR refactors the existing
Event/Listener/EventTypetypes and introduces new typed specializations for build lifecycle events. The design enables PR #13011 to integrate itsRepositoryEvent/RepositoryListenerinto the same hierarchy by simply extendingEventandListener.API changes
Event@Immutable, singlesession()noun-style accessorExecutionEventextends Event) withtype(),project(),mojoExecution(),exception()ExecutionEventTypeEventTypefor clarity, same values in same orderEventType@Deprecated(forRemoval)— alias with bridge methods toExecutionEventTypeExecutionListenerextends Listener) with per-event-typedefaultmethodsListener@FunctionalInterfaceremoved,onEvent()deprecated asdefaultImpl changes
DefaultEvent: implementsExecutionEventwith noun-style accessorsEventSpyImpl: dispatches to both legacyListener.onEvent()and typedExecutionListenercallbacksDesign
Key properties:
Session.registerListener(Listener)handles all listener types — no method overloadingXxxEvent extends Event+XxxListener extends ListenerListener.onEvent()stays as@Deprecated defaultSession.java,AbstractSession.java,SessionStub.javaare unchanged — the existingList<Listener>works for both old and new listener typesRelationship with PR #13011
This PR provides the hierarchy foundation. PR #13011 should merge this, then:
RepositoryEvent extends Event(addsession()accessor)RepositoryListener extends ListenerregisterListener(RepositoryListener)/getRepositoryListeners()methods fromSessionRepositoryEventandRepositoryMetadataThis pull request addresses one issue without unrelated changes.
The description explains what the pull request does, how, and why.
The commit has a meaningful subject and body.
mvn verifypasses.I hereby declare this contribution to be licenced under the Apache License Version 2.0, January 2004